package com.android.bookgarden;

import android.app.Application;

import com.android.bookgarden.bean.UserInfo;
import com.android.bookgarden.utli.MainConstant;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;

import org.xutils.x;

import cn.jpush.android.api.JPushInterface;

/**
 * Create by zouqh
 * on 2018/12/11
 **/
public class MyApplication extends Application {
    public static IWXAPI mWxApi;
    public  UserInfo userInfo;

    private static MyApplication myApplication = null;

    @Override
    public void onCreate() {
        super.onCreate();
        x.Ext.init(this);
        JPushInterface.init(this);
        registerToWX();
    }

    private void registerToWX() {
        //第二个参数是指你应用在微信开放平台上的AppID
        mWxApi = WXAPIFactory.createWXAPI(this, MainConstant.WEIXIN_APP_ID, false);
        // 将该app注册到微信
        mWxApi.registerApp(MainConstant.WEIXIN_APP_ID);
    }

    /**
     * @author xlc
     * 单例模式
     * @time 2018-12-12
     * @return
     */
    public static MyApplication getInstance(){
        if (myApplication == null){
            myApplication = new MyApplication();
        }
        return myApplication;
    }

}
